package com.wanhau.quartz;

import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

public class JobRun {
	public static void main(String[] args) {
		JobDetail jobDetail = JobBuilder.newJob(MyJob.class)
				.usingJobData("aa", "aa")
				.usingJobData("bb", 1F)
				.withIdentity("JOb", "GROUP").build();
		Trigger trigger = TriggerBuilder.newTrigger()
				.withIdentity("TRIGGER", "GROUP")
				.usingJobData("aa", "aaa")
				.usingJobData("bbb", 2F)
				.withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(2))
				.startNow().build();
		SchedulerFactory factory = new StdSchedulerFactory();
		try {
			Scheduler scheduler = factory.getScheduler();
			scheduler.scheduleJob(jobDetail, trigger);
			scheduler.start();
		} catch (SchedulerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
